package com.zhanghu.backendZray.converter;

import com.zhanghu.backendZray.pojo.entity.Role;
import com.zhanghu.backendZray.pojo.request.role.RoleRequest;
import com.zhanghu.backendZray.pojo.vo.RoleVo;
import org.springframework.stereotype.Component;

/**
 * @author ZhangDong
 * @date 2024/7/24 16:05
 */
@Component
public class RoleConverter extends Converter<RoleRequest, Role, RoleVo> {
    public RoleConverter() {
        super(RoleConverter::request2Role, RoleConverter::Role2Vo);
    }

    private static Role request2Role(RoleRequest request) {
        Role Role = new Role();
        Role.setId(request.getId());
        Role.setName(request.getName());
        Role.setEnName(request.getEnName());
        return Role;
    }

    private static RoleVo Role2Vo(Role entity) {
        RoleVo vo = new RoleVo();
        vo.setId(entity.getId());
        vo.setName(entity.getName());
        vo.setEnName(entity.getEnName());
        return vo;
    }
}
